package cn.com.dcsgo.dao.impl;

import cn.com.dcsgo.dao.StudentDao;
import cn.com.dcsgo.pojo.Student;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

/**
 * StudentDao
 *
 * @author Dcsgo
 * @since 2025/2/4 11:26
 */

public class StudentDaoImpl implements StudentDao {
    private final JdbcTemplate jdbcTemplate;

    public StudentDaoImpl(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public List<Student> queryAll() {
        String sql = "select id,name,gender,age,class as classes from studb.students";
        return jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Student.class));
    }
}
